package o;

import android.content.Context;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.huawei.fastengine.fastview.download.utils.UiHelper;
import java.lang.reflect.InvocationTargetException;

public final class dfc {
    private static DisplayMetrics ˏ;

    private static DisplayMetrics ˋ(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        if (context == null) {
            return displayMetrics;
        }
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        try {
            Class.forName("android.view.Display").getMethod("getRealMetrics", new Class[]{DisplayMetrics.class}).invoke(defaultDisplay, new Object[]{displayMetrics});
        } catch (Exception e) {
            Log.w(UiHelper.TAG, "get full display metrics error!" + e.toString());
        }
        return displayMetrics;
    }

    public static int ˊ(Context context) {
        return ˋ(context).widthPixels;
    }

    public static int ˎ(Context context) {
        return ˋ(context).heightPixels;
    }

    public static void ˊ(LayoutParams layoutParams) {
        try {
            layoutParams.getClass().getDeclaredField("layoutInDisplayCutoutMode").setInt(layoutParams, 1);
        } catch (Exception e) {
            Log.w(UiHelper.TAG, "setLayoutMode error");
        }
    }

    public static int ˏ(Context context, int i) {
        if (ˏ == null) {
            ˏ = ˏ(context);
        }
        return (int) (((float) i) * ˏ.density);
    }

    private static DisplayMetrics ˏ(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        if (context != null) {
            ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        }
        return displayMetrics;
    }

    public static void ˎ(LayoutParams layoutParams) {
        try {
            Class cls = Class.forName("com.huawei.android.view.WindowManagerEx$LayoutParamsEx");
            Object newInstance = cls.getDeclaredConstructor(new Class[]{LayoutParams.class}).newInstance(new Object[]{layoutParams});
            cls.getDeclaredMethod("setDisplaySideMode", new Class[]{Integer.TYPE}).invoke(newInstance, new Object[]{Integer.valueOf(1)});
        } catch (InstantiationException e) {
            Log.e(UiHelper.TAG, "setLayoutInDisplaySideMode InstantiationException");
        } catch (InvocationTargetException e2) {
            Log.e(UiHelper.TAG, "setLayoutInDisplaySideMode InvocationTargetException");
        } catch (NoSuchMethodException e3) {
            Log.e(UiHelper.TAG, "setLayoutInDisplaySideMode NoSuchMethodException");
        } catch (IllegalAccessException e4) {
            Log.e(UiHelper.TAG, "setLayoutInDisplaySideMode IllegalAccessException");
        } catch (ClassNotFoundException e5) {
            Log.e(UiHelper.TAG, "setLayoutInDisplaySideMode ClassNotFoundException");
        }
    }
}
